package 多客户端上传文件到一个服务器;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

public class ClientDemo {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		Socket s = new Socket("zc521106", 9099);
		BufferedInputStream bis = new BufferedInputStream(new FileInputStream(
				"E:/java/FileTest/hh.txt"));
		BufferedOutputStream bos = new BufferedOutputStream(s.getOutputStream());
		BufferedReader br = new BufferedReader(new InputStreamReader(
				s.getInputStream()));
		int read;
		byte[] data=new byte[1024];
		while((read=bis.read(data))!=-1){
			bos.write(data, 0, read);
			bos.flush();
		}
		s.shutdownOutput();
		String recback=br.readLine();
		System.out.println(recback);
		s.close();
	}

}
